import { toast } from './util';

export const uniLogin = (type: any) => {
  return new Promise(resolve => {
    // #ifdef MP-WEIXIN
    uni.login({
      provider: type, //'weixin', //使用微信登录
      success: res => {
        if (res.code) {
          resolve(res.code);
        } else {
          toast('获取code失败');
        }
      },
      fail: () => {
        toast('获取code失败');
      },
    });
    // #endif
    // #ifdef H5
    resolve('');
    // #endif
  });
};
